﻿namespace BusinessLogic.Mappers.CurrencyConversion.Mapping
{
	internal class CurrencyConversionMapping : IMapping<BusinessEntity.Entities.CurrencyConversion, DataControl.Cur_exchange>
	{
		public BusinessEntity.Entities.CurrencyConversion ToBE(DataControl.Cur_exchange from)
		{
			var to = new BusinessEntity.Entities.CurrencyConversion();

			to.ConversionRate = from.Price;
			to.ID = from.Id_cur_exchange;
			to.SourceCurrency = new BusinessEntity.Entities.Currency {ID = from.Id_currency_1};
			to.TargetCurrency = new BusinessEntity.Entities.Currency {ID = from.Id_currency_2};

			return to;
		}

		public DataControl.Cur_exchange ToDTO(BusinessEntity.Entities.CurrencyConversion from)
		{
			var to = new DataControl.Cur_exchange();

			to.Id_cur_exchange = from.ID;
			to.Price = from.ConversionRate;
			to.Id_currency_1 = from.SourceCurrency.ID;
			to.Id_currency_2 = from.TargetCurrency.ID;

			return to;
		}
	}
}
